<template>
	<view class="card">
		<view class="title">
			<slot name="title">
				这是v-shot:title
			</slot>
		</view>
		<view class="content">
			<template v-for="(item,index) in contents.list">
				<view class="content-item" @click="itemClick(item,index)">
					<text class="iconfont d-icon" :class="item.icon" style="font-size: 60rpx;"
						:style="{color: item.color}"></text>
					<text class="text">{{item.desc}}</text>
				</view>
			</template>
		</view>

	</view>
</template>

<script>
	import {
		loginRelease
	} from "@/utils/common.js"
	export default {
		name: "card-show",
		props: {
			contents: {
				type: Object,
				default () {
					return {}
				}
			}
		},
		data() {
			return {

			};
		},
		methods: {
			async itemClick(item, index) {
				try {
					if (item.type != 'emit') {
						const result = this.contents.before(item)
						if (result.status == 'success') {
							uni.navigateTo({
								url: item.path
							})
							// this.notLoginPage.includes(item.effect) ?
							// 	uni.navigateTo({
							// 		url: item.path
							// 	}) :
							// 	await loginRelease()
							// uni.navigateTo({
							// 	url: item.path
							// })
						} else {
							uni.showToast({
								title: result.error,
								icon: 'none'
							})
						}
						return
						// console.log('t');

					}
					this.$emit('EmitClick', {
						item,
						index
					})
				} catch (e) {
					console.log('伪错误', e);
				}
			}
		},
	}
</script>

<style lang="scss" scoped>
	.card {
		box-sizing: border-box;
		background-color: #fff;
		border-radius: 20rpx;
		padding: 20rpx;
	}

	.title {
		font-weight: bold;
		// margin-left: 20rpx;
		margin-bottom: 40rpx;
	}

	.content {
		display: flex;
		flex-wrap: wrap;
	}

	.content-item {
		flex-basis: 25%;
		display: flex;
		flex-direction: column;
		align-items: center;
		margin-bottom: 30rpx;
		font-size: 24rpx;
	}

	.content-item .d-icon {
		// width: 64rpx;
	}

	.content-item .text {
		margin-top: 15rpx;
	}
</style>